from fastapi import FastAPI

from config import ServiceConfig
from apps.libs.exception import register_exception
from .endpoints import (
    base
)


def register_routers(app: FastAPI):
    """register routers"""

    app.include_router(base.router, prefix='/base', tags=['base'])


def init_sub_app(app: FastAPI) -> FastAPI:
    """mount sub app"""

    sub_app: FastAPI = FastAPI(include_in_schema=ServiceConfig.INCLUDE_IN_SCHEMA)

    register_exception(sub_app)
    register_routers(sub_app)
    app.mount(path='/api', app=sub_app, name='api_app')

    return app
